#include "GameArea.h"
#include <QTimerEvent>
#include <QMessageBox>
#include <QKeyEvent>
#include <QTime>


#define RECT_COLUMES	15
#define RECT_ROWS		20
#define RECT_WIDTH		40
#define RECT_HEIGHT		40

//默认出生点 x方向
#define DEFAULT_BORN_POS_X    (RECT_COLUMES / 2 - 1)





void GameArea::paintEvent(QPaintEvent *)
{
    //绘制左侧游戏区域
    DrawBKRects();
    DrawFixedRects();
    DrawCurItem();

    update();
}

void GameArea::DrawBKRects()
{
    QPainter painter(this);
    painter.setBrush(QColor("#696969"));
    painter.setPen(Qt::NoPen);

    for(int i = 0;i<RECT_COLUMES; i++)
    {
        for (int j = 0; j<RECT_ROWS; j++)
        {
            if (i == 0 || i == RECT_COLUMES - 1 || j==0 || j==RECT_ROWS-1)
            {
                painter.drawRect( i*RECT_WIDTH,j*RECT_HEIGHT,RECT_WIDTH,RECT_HEIGHT);
            }
        }
    }
}

void GameArea::DrawFixedRects()
{
    QPainter painter(this);
    painter.setBrush(QColor("#D3D3D3"));
    painter.setPen(QPen(QColor(Qt::black),1));


}

void GameArea::DrawCurItem()
{
    QPainter painter(this);
    painter.setBrush(QColor("#FFDEAD"));
    painter.setPen(QPen(QColor(Qt::black),1));


}
